package speedball;

import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.util.Duration;

public class ClickEvent {

	
	public static void setCilckToggle(boolean borderVaryFlag,Rectangle progressBar,Rectangle progressValue,Ellipse  top,Shape ripple,Shape ripple2,Shape ripple3,Circle air1,Circle air2,Circle air3,Shape right,GridPane gridPane,Button expand,Label number,Label percent,Circle circle ,ParallelTransition parallelTransition,ParallelTransition parallelTransition2,ParallelTransition parallelTransition3) {
		double duration = 500L;
		int cycleCount = 1;
		if (borderVaryFlag) {
			progressBar.setVisible(borderVaryFlag);
			progressValue.setVisible(borderVaryFlag);
			top.setVisible(borderVaryFlag);
			//progressBar,progressValue,top
			
//			FadeTransition ft5 = new FadeTransition(Duration.millis(duration - 400), progressBar);
//			ft5.setFromValue(0.0);
//			ft5.setToValue(1.0);
//			ft5.setCycleCount(1);
//			ft5.setAutoReverse(false);
//			ft5.play();
//			
//			
//			ft5 = new FadeTransition(Duration.millis(duration - 400), progressValue);
//			ft5.setFromValue(0.0);
//			ft5.setToValue(1.0);
//			ft5.setCycleCount(1);
//			ft5.setAutoReverse(false);
//			ft5.play();
//			
//			
//			ft5 = new FadeTransition(Duration.millis(duration - 400), top);
//			ft5.setFromValue(0.0);
//			ft5.setToValue(1.0);
//			ft5.setCycleCount(1);
//			ft5.setAutoReverse(false);
//			ft5.play();
			
			
			
			//ripple, ripple2, ripple2, ripple3, air1, air2, air3, right, gridPane, expand, number, percent, circle
			FadeTransition ft5 = new FadeTransition(Duration.millis(duration + 200), ripple);
			ft5.setFromValue(0.60D);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();

			
			ft5 = new FadeTransition(Duration.millis(duration + 200), ripple2);
			ft5.setFromValue(0.70D);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), ripple3);
			ft5.setFromValue(0.80D);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
//			ft5 = new FadeTransition(Duration.millis(duration + 200), air1);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
//			
//			ft5 = new FadeTransition(Duration.millis(duration + 200), air2);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
//			ft5 = new FadeTransition(Duration.millis(duration + 200), air3);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), right);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();

			FadeTransition ft4 = new FadeTransition(Duration.millis(duration + 200), gridPane);
			ft4.setFromValue(1.0);
			ft4.setToValue(0.0);
			ft4.setCycleCount(cycleCount);
			ft4.setAutoReverse(true);
			ft4.play();

			ft5 = new FadeTransition(Duration.millis(duration + 200), expand);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), number);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), percent);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), circle);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();	
			
			parallelTransition.stop();
			parallelTransition2.stop();
			parallelTransition3.stop();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), air1);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(1);
//			ft5.setAutoReverse(false);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration + 200), air2);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(1);
			ft5.setAutoReverse(false);
			ft5.play();
			ft5 = new FadeTransition(Duration.millis(duration + 200), air3);
			ft5.setFromValue(1.0);
			ft5.setToValue(0.0);
			ft5.setCycleCount(1);
			ft5.setAutoReverse(false);
			ft5.play();
			
			borderVaryFlag = !borderVaryFlag;
		} else {
			progressBar.setVisible(borderVaryFlag);
			progressValue.setVisible(borderVaryFlag);
			top.setVisible(borderVaryFlag);
			//progressBar,progressValue,top
//			FadeTransition ft5 = new FadeTransition(Duration.millis(duration - 400), progressBar);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
//			
//			
//			ft5 = new FadeTransition(Duration.millis(duration - 400), progressValue);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
//			
//			
//			ft5 = new FadeTransition(Duration.millis(duration - 400), top);
//			ft5.setFromValue(1.0);
//			ft5.setToValue(0.0);
//			ft5.setCycleCount(cycleCount);
//			ft5.setAutoReverse(true);
//			ft5.play();
			
			
			//ripple, ripple2, ripple2, ripple3, air1, air2, air3, right, gridPane, expand, number, percent, circle
			FadeTransition ft5 = new FadeTransition(Duration.millis(duration - 400), ripple);
			ft5.setFromValue(0.0);
			ft5.setToValue(0.60D);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration - 400), ripple2);
			ft5.setFromValue(0.0);
			ft5.setToValue(0.70D);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration - 400), ripple3);
			ft5.setFromValue(0.0);
			ft5.setToValue(0.80D);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			
			ft5 = new FadeTransition(Duration.millis(duration - 400), right);
			ft5.setFromValue(0.0);
			ft5.setToValue(1.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();
			ft5 = new FadeTransition(Duration.millis(duration - 400), expand);
			ft5.setFromValue(0.0);
			ft5.setToValue(1.0);
			ft5.setCycleCount(cycleCount);
			ft5.setAutoReverse(true);
			ft5.play();

			FadeTransition ft4 = new FadeTransition(Duration.millis(duration - 400), gridPane);
			ft4.setFromValue(0.0);
			ft4.setToValue(1.0);
			ft4.setCycleCount(cycleCount);
			ft4.setAutoReverse(true);
			ft4.play();

			ft4 = new FadeTransition(Duration.millis(duration - 400), number);
			ft4.setFromValue(0.0);
			ft4.setToValue(1.0);
			ft4.setCycleCount(cycleCount);
			ft4.setAutoReverse(true);
			ft4.play();
			
			ft4 = new FadeTransition(Duration.millis(duration - 400), percent);
			ft4.setFromValue(0.0);
			ft4.setToValue(1.0);
			ft4.setCycleCount(cycleCount);
			ft4.setAutoReverse(true);
			ft4.play();
			
			ft4 = new FadeTransition(Duration.millis(duration - 400), circle);
			ft4.setFromValue(0.0);
			ft4.setToValue(1.0);
			ft4.setCycleCount(cycleCount);
			ft4.setAutoReverse(true);
			ft4.play();

			parallelTransition.play();
			parallelTransition2.play();
			parallelTransition3.play();
			
			borderVaryFlag = !borderVaryFlag;
		}
		
		
		
	}
}
